package com.mpush.api.chat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 聊天消息
 * 
 * @author gary.zhi
 * @date Jul 19, 2018 5:08:33 PM
 */
public class ChatMessage {

	private Long id;

	/**
	 * 会话id
	 */
	private Long sessionId;

	/**
	 * 发送者用户id
	 */
	private String senderId;

	/**
	 * 发送者姓名
	 */
	private String senderName;

	/**
	 * 接收者用户id
	 */
	private String receiverId;

	/**
	 * 接收者姓名
	 */
	private String receiverName;

	/**
	 * 消息类型(0=文本，1=图片，2=语音，3=视频，4=定位)
	 */
	private String type;

	/**
	 * 消息
	 */
	private String msgContent;
	
	private Long sendTime;

	private Integer duration;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getSessionId() {
		return sessionId;
	}

	public void setSessionId(Long sessionId) {
		this.sessionId = sessionId;
	}

	public String getSenderId() {
		return senderId;
	}

	public void setSenderId(String senderId) {
		this.senderId = senderId;
	}

	public String getSenderName() {
		return senderName;
	}

	public void setSenderName(String senderName) {
		this.senderName = senderName;
	}

	public String getReceiverId() {
		return receiverId;
	}

	public void setReceiverId(String receiverId) {
		this.receiverId = receiverId;
	}

	public String getReceiverName() {
		return receiverName;
	}

	public void setReceiverName(String receiverName) {
		this.receiverName = receiverName;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getMsgContent() {
		return msgContent;
	}

	public void setMsgContent(String msgContent) {
		this.msgContent = msgContent;
	}

	public Long getSendTime() {
		return sendTime;
	}

	public void setSendTime(Long sendTime) {
		this.sendTime = sendTime;
	}

	public Integer getDuration() {
		return duration;
	}

	public void setDuration(Integer duration) {
		this.duration = duration;
	}

	public Map<String, String> toParam() {

		Map<String, String> param = new HashMap<>(0);
		param.put("id", null != id ? id.toString() : "");
		param.put("sessionId", null != sessionId ? sessionId.toString() : "");
		param.put("senderId", null != senderId ? senderId : "");
		param.put("senderName", null != senderName ? senderName : "");
		param.put("receiverId", null != receiverId ? receiverId : "");
		param.put("receiverName", null != receiverName ? receiverName : "");
		param.put("type", null != type ? type : "");
		param.put("msgContent", null != msgContent ? msgContent : "");
		param.put("duration", null != duration ? duration.toString() : "");

		return param;
	}

	public ChatMessage clone() {
		ChatMessage chatMessage = new ChatMessage();
		chatMessage.setId(id);
		chatMessage.setSessionId(sessionId);
		chatMessage.setSenderId(senderId);
		chatMessage.setSenderName(senderName);
		chatMessage.setReceiverId(receiverId);
		chatMessage.setReceiverName(receiverName);
		chatMessage.setType(type);
		chatMessage.setMsgContent(msgContent);
		chatMessage.setSendTime(sendTime);
		chatMessage.setDuration(duration);
		return chatMessage;
	}
}
